// 给定一个已排序的链表的头 head，删除所有重复的元素，使每个元素只出现一次 。返回已排序的链表
ListNode* deleteDuplicates(ListNode* head) {
    if(!head) return head;

    ListNode *pre = head, *cur = pre->next;
    while(cur)
    {
        if(cur->val == pre->val)
        {
            cur = cur->next;
            pre->next = cur;
        }
        else
        {
            cur = cur->next;
            pre = pre->next;
        }
    }
    return head;
}